#include "StdAfx.h"
#include "TwTextureUVPlay.h"
#include "TwRenderSurfaceDx.h"

TwTextureUVPlay::TwTextureUVPlay(void):
m_pkSurface(0)
{
}

TwTextureUVPlay::~TwTextureUVPlay(void)
{
}
void TwTextureUVPlay::SetSurface(void* pkSrface)
{
	if(pkSrface == NULL)
		return;
	m_pkSurface = (TwRenderSurfaceDx*)pkSrface;

	Pointer p;
	p.byte = m_pkSurface->pkVertexs;

	for (int n = 0; n < 4; ++n)
	{
		p.f +=4;
		p.dw +=1;
		m_pkUV[n] =  p.f;
		p.f += 2;
	}
}
void TwTextureUVPlay::Update()
{
	if(m_pkSurface == NULL)
		return;
	static DWORD dwTime = GetTickCount();
	static float uf = 0.0005f;
	if(GetTickCount() - dwTime > 100)
	{
		dwTime = GetTickCount();
		if(*(m_pkUV[3]) > 0.95f || *(m_pkUV[0]) < 0.000f)
			uf = -uf;
		*(m_pkUV[0]) +=  uf;
		*(m_pkUV[1]) +=  uf;
		*(m_pkUV[2]) = *(m_pkUV[0]) + 0.5f;
		*(m_pkUV[3]) = *(m_pkUV[1]) + 0.5f;
	}
}
void TwTextureUVPlay::Render()
{
	if(m_pkSurface == NULL)
		return;
	
}